﻿using System;
using System.Collections.Generic;
using MossDAL.DotNet.ServiceHelpers;
using MossDAL.Samples;
//using MossDAL.DotNet;

namespace linqforlistitems
{
    class Program
    {
        
        ////<Query><Where><Eq><FieldRef Name="show_x0020_in_x0020_viewer" /><Value Type="Boolean">True</Value></Eq></Where><OrderBy><FieldRef Name="display_x0020_order" Ascending="True" /></OrderBy></Query>
        //private readonly XElement Query = XElement.Parse("<Query><Where><Eq><FieldRef Name='show_x0020_in_x0020_viewer' /><Value Type='Boolean'>True</Value></Eq></Where><OrderBy><FieldRef Name='display_x0020_order' Ascending='True' /></OrderBy></Query>");

        ////<ViewFields><FieldRef Name="Title" /><FieldRef Name="project" /><FieldRef Name="client" /><FieldRef Name="ImageWidth" /><FieldRef Name="ImageHeight" /><FieldRef Name="Description" /><FieldRef Name="show_x0020_in_x0020_viewer" /><FieldRef Name="display_x0020_order" /></ViewFields>
        //private readonly XElement ViewFields = XElement.Parse("<ViewFields><FieldRef Name='Title' /><FieldRef Name='project' /><FieldRef Name='client' /><FieldRef Name='ImageWidth' /><FieldRef Name='ImageHeight' /><FieldRef Name='Description' /><FieldRef Name='show_x0020_in_x0020_viewer' /><FieldRef Name='display_x0020_order' /><FieldRef Name='url' /></ViewFields>");

        ////<QueryOptions />
        //private readonly XmlNode QueryOptions =  XElement.Parse("<QueryOptions />");
        
        static void Main(string[] args)
        {
            DotNetServiceHelper<SiteGalleryListItem> svcHelper = new DotNetServiceHelper<SiteGalleryListItem>();
            svcHelper.Credentials = new System.Net.NetworkCredential("administrator", "thefuture", "sharepoint");
            svcHelper.PageSize = 50;
            svcHelper.SharepointHostname = "sharepoint";

            IList<SiteGalleryListItem> items = svcHelper.FetchListItems(ApplicationQueries.GetSiteGalleryItems());

            foreach (SiteGalleryListItem item in items)
            {
                Console.WriteLine(item.ID);
                Console.WriteLine(item.client);
                Console.WriteLine(item.Description);
                Console.WriteLine(item.DisplayOrder);
                Console.WriteLine(item.ImageHeight);
                Console.WriteLine(item.ImageWidth);
                Console.WriteLine(item.project);
                Console.WriteLine(item.ShowInViewer);
                Console.WriteLine(item.Title);
                Console.WriteLine(item.url);
                Console.WriteLine();
            }
            Console.ReadKey();
        }
    }
}
